<?php 
//simple script to display graph using input "DOT Language"
//expected parameters: 
//  graph:  file name relative to "ROOT/graph/" directory
//  format: output format: svg, gif, png, jpg, ... and others supported by dot language.

$format='svg';
$graph='default';
if(isset($_GET['format']))$format=$_GET['format'];
if(isset($_GET['graph']))$graph=$_GET['graph'];

static $mimes = array(
    'svg' => 'image/svg+xml',
    'gif' => 'image/gif',
    'png' => 'image/png',
    'jpg' => 'image/jpeg',
 );

if(isset($mimes[$format]))
	header("Content-type: ".$mimes[$format]);
else
	header("Content-type: text/xml");


require_once('apm-conf.inc');
include_once('lib/dot.php.inc');

readfile ( dot($graph,$format) );
